import request from "@/util/request";

/**
 * 手机号登录
 */
export const auth = (encryptedData, iv, code, registType, grant_type,spreadId) => request({
  url: '/blade-auth/oauth/token',
  method: 'post',
  params: {
    grant_type,
    code,
	encryptedData,
	iv,
    registType,
	spreadId
  }
});

/**
 * 用户名登录
 */
export const loginByUsername = (avatarUrl, nickName, city, country, province, gender, code, registType, grant_type,spreadId) => request({
  url: '/blade-auth/oauth/token',
  method: 'post',
  params: {
    grant_type,
    code,
    avatarUrl,
    nickName,
    city,
    country,
    province,
    gender,
    registType,
	spreadId
  }
});

/**
 * 静默登录token
 */
export const silenceAuth = (code, registType,spreadId) => request({
  url: '/blade-auth/oauth/token',
  method: 'post',
  params: {
    grant_type:"app",
    code,
    registType,
	silenceAuth:1,
	spreadId
  }
});

export const logout = () => request({
  url: '/blade-auth/oauth/logout'
});

export const getUserInfo = () => request({
  url: '/qichong-record/api/user/info'
});

/**
 * 更新会员信息
 * @param {Object} data
 */
export const updateUserInfo = (data) => request({
  url: '/enjooo-api/member/updateUserInfo',
  method: 'post',
  data
});

/**
 * 获取会员卡页面数据
 */
export const getMemberCard = () => request({
  url: '/enjooo-api/member/card/index'
});

export const uploadFile = (file) => request({
  url: '/blade-resource/oss/endpoint/put-file',
  method: 'post',
  data: {
    file
  }
});


export const removeFile = (file) => request({
  url: '/blade-resource/oss/endpoint/remove-file',
  method: 'post',
  params: {
    fileName: file
  }
});


export const vipCard = () => request({
  url: '/qichong-record/vipcard/getAllVipCard',
  method: 'get',
})

export const buyCard = (commodityId, orderType, shopId) => request({
  url: '/qichong-record/order/create',
  method: 'post',
  data: {
    commodityId,
    orderType,
    shopId
  }
})

export const bindWxPhone = (encryptedData, iv, code) => request({
  url: '/blade-user/wechat/bind-phone',
  method: 'post',
  data: {
    encryptedData,
    iv,
    code
  }
});

// 查看用户是否有会员卡
export const getUserVip = () => request({
  url: '/qichong-record/uservip/isUserVip',
  showLoading: false
});

// 修改用户信息
export const getUserUpdate = (user) => request({
  url: '/blade-user/updateUserById',
  method: 'post',
  data: user
});


// 退出登录
export const logoutUser = () => request({
  url: '/blade-auth/oauth/logout',
});


// 意见反馈
export const Userfeedback = (feedBack) => request({
  url: '/blade-system/feedback/save',
  method: 'post',
  data: feedBack
});

// 根据用户id获取所有的宠物档案
export const RecordUserId = () => request({
  url: '/qichong-record/api/animal/me',
  showLoading: false
});


// 品种根据模糊搜索
export const SearchInputAll = (key) => request({
  url: '/qichong-record/api/category/search',
  params: {
    key
  }
});

// 根据用户id获取用户数据
export const examineUserInfo = (userId) => request({
  url: '/qichong-record/api/user/home',
  params: {
    userId
  }
});

// 根据用户id获取关于ta数据
export const regardUserInfo = (userId) => request({
  url: '/qichong-record/api/user/ta',
  params: {
    userId
  }
});

// 根据用户id获取文章数据
export const articleUserInfo = (userId) => request({
  url: '/qichong-record/api/user/articles',
  params: userId
});

// 根据用户id获取动态数据
export const dynamicUserInfo = (userId) => request({
  url: '/qichong-record/api/user/posts',
  params: userId
});

// 根据用户id获取喜欢数据
export const likeUserInfo = (userId) => request({
  url: '/qichong-record/api/user/likes',
  params: userId
});

// 根据用户id获取想买数据
export const marketUserInfo = (userId) => request({
  url: '/qichong-record/api/user/haves',
  params: userId
});


// 更改用户简介
export const updatebrief = (remarks) => request({
  url: '/qichong-record/api/user/modify',
  method: 'post',
  params: {
    remarks
  }
});

export const phoneInfo = (encryptedData, iv, code) => request({
  url: '/qichong-record/api/user/bind-phone',
  method: 'post',
  data: {
    encryptedData,
    iv,
    code
  }
});

/**
 * 获取会员码
 */
export const memberCode = () => request({
  url: '/qichong-record/api/user/memberCode'
});

/**
 * 获取邀请码
 */
export const inviteCode = () => request({
  url: '/qichong-record/api/user/inviteCode'
});
